package com.corpgovernment.common.utils;

import com.corpgovernment.common.common.CorpBusinessException;
import com.corpgovernment.common.constant.CommonResponseCodeEnum;
import com.corpgovernment.common.dto.UserCardValidationInfoReqVo;
import com.corpgovernment.common.enums.CardEnum;
import com.ctrip.corp.obt.generic.utils.JsonUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import java.util.Objects;
import java.util.regex.Pattern;

import static java.lang.Math.pow;

/**
 * @author tkang
 * 证件验证工具
 */
@Slf4j
public class CardValidateUtil {
    private static final int FIFTEEN = 15;
    private static final int EIGHTEEN = 18;

    public  static boolean validateUserCard(UserCardValidationInfoReqVo userCardInfoVo) {
        if(Objects.isNull(userCardInfoVo)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO);
        }
        Integer cardType = userCardInfoVo.getCardType();
        String cardNo = userCardInfoVo.getCardNo();
        if(Objects.isNull(cardType) || StringUtils.isBlank(cardNo)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO);
        }
        String cardTypeStr = String.valueOf(cardType);
        CardEnum cardCodeEnum = CardEnum.get(cardTypeStr);
        //不支持的证件
        if(Objects.isNull(cardCodeEnum)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO);

        }
        switch (cardCodeEnum) {
            case ID_CARD:
                userCardInfoVo.setCardNo(userCardInfoVo.getCardNo().toUpperCase());
                validateIdCard(userCardInfoVo);
                break;
            case PASSPROT:
                validatePassport(userCardInfoVo);
                break;
            case SOLDIER_CARD:
                validateSoldierCard(userCardInfoVo);
                break;
            case RETURN_HOME_CARD:
                validateReturnHomeCard(userCardInfoVo);
                break;
            case TAIWAN_CARD:
                validateTaiWanCard(userCardInfoVo);
                break;
            case GANGAO_CARD:
                validateGangAoCard(userCardInfoVo);
                break;
            case FOREIGNER_CARD:
                validateForeignerCard(userCardInfoVo);
                break;
            case TRAVEL_CARD:
                validateTravelCard(userCardInfoVo);
                break;
            case TAIWAN_PASS:
                validateTaiWanPassCard(userCardInfoVo);
                break;
            case BOOKLET:
                validateBookLetCard(userCardInfoVo);
                break;
            case BIRTH_CERTIFICATE:
                validateBirthCertificate(userCardInfoVo);
                break;
            case FOREIGNER_LIVE_CARD:
                validateForeignerLiveCardNew(userCardInfoVo);
                break;
            case GANGAO_LIVE_CARD:
                validateGangAoLiveCard(userCardInfoVo);
                break;
            case ELSE:
                validateElseCard(userCardInfoVo);
                break;
            default:
                break;
        }
        return true;
    }

    public static boolean validateIdCard(UserCardValidationInfoReqVo userCardInfoVo) {
        log.info("当前校验的证件信息为:{}", JsonUtils.toJsonString(userCardInfoVo));
        String pattern = "^\\d{17}(\\d|X)$";
        String idCardNo = userCardInfoVo.getCardNo();
        if (!idCardNo.matches(pattern)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO_FOR_TYPE);
        }
        // 验证身份证出生日期
        String birthday = idCardNo.substring(6, 14);
        if (!isValidIdCardBirthday(birthday)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO_FOR_TYPE);
        }
        // 验证校验码
        if (!isValidIdCardCheckCode(idCardNo)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO_FOR_TYPE);
        }
        //以 810000, 820000 或 830000 的形式开头可能是港澳台居民居住证
        if (idCardNo.startsWith("810000") || idCardNo.startsWith("820000") || idCardNo.startsWith("830000")) {
            throw new CorpBusinessException(CommonResponseCodeEnum.PLEASE_CHOOSE_GANGAO_CARD);

        }
           /*     if(!isValidCnName(userCardInfoVo.getCnName())) {
           throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_NAME);
        }*/
        return true;
    }

    /**
     * 中文名称校验
     * @param name
     * @return
     */
    public static boolean isValidCnName(String name) {
        /**
         * 首字母需为中文，可以用字母结尾，但字母后面不能接中文
         * 不支持空格和特殊字符
         * 1-100个字符
         */
        if(StringUtils.isBlank(name)) {
            return false;
        }
        if (name.length() < 1 || name.length() > 100) {
            return false;
        }

        char firstChar = name.charAt(0);
        if (!isChineseCharacter(firstChar)) {
            return false;
        }

        for (int i = 1; i < name.length(); i++) {
            char currentChar = name.charAt(i);
            if (!isChineseCharacter(currentChar) && !Character.isLetter(currentChar)) {
                return false;
            }
            if (Character.isLetter(currentChar) && i < name.length() - 1 && isChineseCharacter(name.charAt(i + 1))) {
                return false;
            }
        }

        return true;
    }

    public static boolean isChineseCharacter(char c) {
        return c >= '\u4E00' && c <= '\u9FFF';
    }


    public static boolean isValidIdCardBirthday(String birthday) {
        //出生日期码中，第7-10位只能为 1900~2100，第11-12位只能为 01~12，第13-14位只能为 01~31
        int year = Integer.parseInt(birthday.substring(0, 4));
        int month = Integer.parseInt(birthday.substring(4, 6));
        int day = Integer.parseInt(birthday.substring(6, 8));

        if (year < 1900 || year > 2100 || month < 1 || month > 12 || day < 1 || day > 31) {
            return false;
        }

        return true;
    }

    /**
     * 身份号码验证码校验
     * @param idCardNumber
     * @return
     */
    public static boolean isValidIdCardCheckCode(String idCardNumber) {
        int index, sum, num = 0;
        for (sum = index = 0; index < 17; index++) {
            sum += (pow(2, 17 - index) % 11) * (idCardNumber.charAt(index) - '0');
            num = (12 - (sum % 11)) % 11;
        }
        char checkCode = idCardNumber.charAt(17);
        if (num < 10) {
            return (num == checkCode - '0');
        } else {
            return (checkCode == 'X');
        }
    }

    public static boolean validatePassport(UserCardValidationInfoReqVo userCardInfoVo) {
        String cardNo = userCardInfoVo.getCardNo();
        //证件号码验证
        if(!validateCommonCardNo(cardNo)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO);
        }
        //校验证件有效时间
        if(!validateCardTimeLimit(userCardInfoVo.getTimeLimit())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_EXPIRATION_DATE);
        }
        //校验生日
    /*    if(!validateBirthday(userCardInfoVo.getBirthday())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_BIRTHDAY);
        }*/

/*        //校验法定姓氏（英文）
        if(!isValidEnName(userCardInfoVo.getLastName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_LAST_NAME);
        }*/
        //校验法定名称（英文）
/*        if(!isValidEnName(userCardInfoVo.getFirstName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_FIRST_NAME);
        }*/

        return true;
    }

    public static boolean isValidEnName(String enName) {
        /**
         * 必须为英文或空格（如Carrie Lam Cheng），首字母为英文
         * 不支持特殊字符
         * 1-100个字符
         */
        if(StringUtils.isBlank(enName)) {
            return false;
        }
        if (!enName.matches("[A-Za-z][A-Za-z ]{0,99}")) {
            return false;
        }
        return true;
    }


    /**
     *
     * @param birthDayStr
     * @return
     */
    public static boolean validateBirthday(String birthDayStr) {
        // 不可为空，仅能选择当日至前100年内的时间
        if(StringUtils.isBlank(birthDayStr)) {
            return false;
        }
        Date birthdate = DateUtil.stringToDate(birthDayStr, DateUtil.DF_YMD);
        if(birthdate == null) {
            return false;
        }
        LocalDate today = LocalDate.now();
        LocalDate endDate = today.minusYears(100);
        LocalDate birthday = birthdate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
        if(birthday.isAfter(today) || birthday.isBefore(endDate)) {
            return false;
        }
        return true;

    }

    /**
     * 证件有效期校验
     * @param cardTimeLimit
     * @return
     */
    public static boolean validateCardTimeLimit(Date cardTimeLimit) {
        if(cardTimeLimit == null) {
            return false;
        }
        LocalDate today = LocalDate.now();
        LocalDate timeLimitEndDate = today.plusYears(100);
        LocalDate  timeLimitEnd = cardTimeLimit.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
        if(timeLimitEnd.isBefore(today) || timeLimitEnd.isAfter(timeLimitEndDate)) {
            return false;
        }
        return true;

    }

    public static boolean validateCommonCardNo(String cardNo) {
        /**
         * 规则：3～25位，仅数字或字母
         */
        String pattern = "^[a-zA-Z0-9]{3,25}$";
        if(! Pattern.matches(pattern, cardNo)) {
            return false;
        }
        return true;
    }

    public static boolean validateSoldierCard(UserCardValidationInfoReqVo userCardInfoVo) {
        String cardNo = userCardInfoVo.getCardNo();
        //校验证件号
        if(!validateCommonCardNo(cardNo)) {
           throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO);
        }
     /*   //校验证件有效期
        if (!validateCardTimeLimit(userCardInfoVo.getTimeLimit())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_EXPIRATION_DATE);
        }
        //校验法定姓名（中文）
        if(!isValidCnName(userCardInfoVo.getCnName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_NAME);
        }

        //校验法定姓氏（英文）
        if(!isValidEnName(userCardInfoVo.getLastName())) {
          throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_LAST_NAME);
        }
         //校验法定名称（英文）
        if(!isValidEnName(userCardInfoVo.getFirstName())) {
             throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_FIRST_NAME);
        }
        //校验出生日期
        if(!validateBirthday(userCardInfoVo.getBirthday())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_BIRTHDAY);
        }*/
        return true;
    }

    public static boolean validateReturnHomeCard(UserCardValidationInfoReqVo userCardInfoVo) {
        String cardNo = userCardInfoVo.getCardNo();
        if(!(cardNo.matches("[HM][0-9]{10}") || cardNo.matches("[HM][0-9]{8}"))) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO_FOR_TYPE);
        }
        //校验证件有效期
        if (!validateCardTimeLimit(userCardInfoVo.getTimeLimit())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_EXPIRATION_DATE);
        }
      /*     if(!isValidCnName(userCardInfoVo.getCnName())) {
           throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_NAME);
        }
        //校验法定姓氏（英文）
        if(!isValidEnName(userCardInfoVo.getLastName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_LAST_NAME);
        }
        //校验法定名称（英文）
        if(!isValidEnName(userCardInfoVo.getFirstName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_FIRST_NAME);
        }
        if (!validateBirthday(userCardInfoVo.getBirthday())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_BIRTHDAY);
        }*/


        return true;
    }

    public static boolean validateTaiWanCard(UserCardValidationInfoReqVo userCardInfoVo) {
        String cardNo = userCardInfoVo.getCardNo();
        if (!cardNo.matches("[0-9]{8}")){
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO_FOR_TYPE);
        }
        //校验证件有效期
        if (!validateCardTimeLimit(userCardInfoVo.getTimeLimit())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_EXPIRATION_DATE);
        }
        /*//校验法定姓氏（英文）
        if(!isValidEnName(userCardInfoVo.getLastName ())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_LAST_NAME);
        }
        //校验法定名称（英文）
        if(!isValidEnName(userCardInfoVo.getFirstName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_FIRST_NAME);
        }
        //校验出生日期
        if (!validateBirthday(userCardInfoVo.getBirthday())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_BIRTHDAY);
        }*/
        return true;
    }

    public static boolean validateGangAoCard(UserCardValidationInfoReqVo userCardInfoVo) {
        String cardNo = userCardInfoVo.getCardNo();
        if(!validateCommonCardNo(cardNo)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO);
        }
        //校验证件有效期
        if (!validateCardTimeLimit(userCardInfoVo.getTimeLimit())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_EXPIRATION_DATE);
        }
      /*  if (!isValidCnName(userCardInfoVo.getCnName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_NAME);
        }*/

        return true;
    }

    public static boolean validateForeignerCard(UserCardValidationInfoReqVo userCardInfoVo) {
        String cardNo = userCardInfoVo.getCardNo();
        if(!validateCommonCardNo(cardNo)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO);
        }
        //校验证件有效期
        if (!validateCardTimeLimit(userCardInfoVo.getTimeLimit())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_EXPIRATION_DATE);
        }

      /*   if(!isValidCnName(userCardInfoVo.getCnName())) {
           throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_NAME);
        }*/

        return true;
    }

    public static boolean validateTravelCard(UserCardValidationInfoReqVo userCardInfoVo) {
        String cardNo = userCardInfoVo.getCardNo();
        if(!validateCommonCardNo(cardNo)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO);
        }
        //校验证件有效期
        if (!validateCardTimeLimit(userCardInfoVo.getTimeLimit())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_EXPIRATION_DATE);
        }

        /*if (!isValidCnName(userCardInfoVo.getCnName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_NAME);
        }*/

        return true;
    }

    public static boolean validateTaiWanPassCard(UserCardValidationInfoReqVo userCardInfoVo) {
        String cardNo = userCardInfoVo.getCardNo();
        if(!validateCommonCardNo(cardNo)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO);
        }

        //校验证件有效期
        if (!validateCardTimeLimit(userCardInfoVo.getTimeLimit())) {
          throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_EXPIRATION_DATE);
        }
     /*   if(!isValidCnName(userCardInfoVo.getCnName())) {
           throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_NAME);
        }*/

        return true;
    }

    public static boolean validateBookLetCard(UserCardValidationInfoReqVo userCardInfoVo) {
        String cardNo = userCardInfoVo.getCardNo();
        if(!validateCommonCardNo(cardNo)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO);
        }
  /*      //校验法定姓氏（英文）
        if(!isValidEnName(userCardInfoVo.getLastName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_LAST_NAME);
        }
        //校验法定名称（英文）
        if(!isValidEnName(userCardInfoVo.getFirstName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_FIRST_NAME);
        }
        if(!validateBirthday(userCardInfoVo.getBirthday())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_BIRTHDAY);
        }
       if(!isValidCnName(userCardInfoVo.getCnName())) {
           throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_NAME);
        }*/

        return true;
    }

    public static boolean validateBirthCertificate(UserCardValidationInfoReqVo userCardInfoVo) {
        String cardNo = userCardInfoVo.getCardNo();
        if(!validateCommonCardNo(cardNo)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO);
        }
        //校验法定姓氏（英文）
  /*      if(!isValidEnName(userCardInfoVo.getLastName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_LAST_NAME);
        }
        //校验法定名称（英文）
        if(!isValidEnName(userCardInfoVo.getFirstName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_FIRST_NAME);
        }
        if(!validateBirthday(userCardInfoVo.getBirthday())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_BIRTHDAY);
        }
       if(!isValidCnName(userCardInfoVo.getCnName())) {
           throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_NAME);
        }
*/
        return true;
    }

    public static boolean validateForeignerLiveCardNew(UserCardValidationInfoReqVo userCardInfoVo){
        String cardNo = userCardInfoVo.getCardNo();
        if (EIGHTEEN == cardNo.length()){
            validateIdCard(userCardInfoVo);
        } else {
            validateForeignerLiveCard(userCardInfoVo);
        }
        return true;
    }

    public static boolean validateForeignerLiveCard(UserCardValidationInfoReqVo userCardInfoVo) {
        String cardNo = userCardInfoVo.getCardNo();
        if(!validForeignerLiveCardNo(cardNo)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO_FOR_TYPE);
        }
        //校验法定姓氏（英文）
  /*      if(!isValidEnName(userCardInfoVo.getLastName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_LAST_NAME);
        }
        //校验法定名称（英文）
        if(!isValidEnName(userCardInfoVo.getFirstName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_FIRST_NAME);
        }
        if(!validateBirthday(userCardInfoVo.getBirthday())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_BIRTHDAY);
        }
       if(!isValidCnName(userCardInfoVo.getCnName())) {
           throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_NAME);
        }
*/
        return true;
    }

    public static boolean validateGangAoLiveCard(UserCardValidationInfoReqVo userCardInfoVo) {
        String pattern = "^\\d{17}(\\d|X)$";
        String idCardNo = userCardInfoVo.getCardNo();
        if (!(idCardNo.startsWith("810000") || idCardNo.startsWith("820000") || idCardNo.startsWith("830000"))) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO_FOR_TYPE);

        }
        if (!idCardNo.matches(pattern)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO_FOR_TYPE);
        }
     /*   if(!isValidCnName(userCardInfoVo.getCnName())) {
           throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_NAME);
        }*/

        // 验证身份证出生日期
        String birthday = idCardNo.substring(6, 14);
        if (!isValidIdCardBirthday(birthday)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO_FOR_TYPE);
        }
        // 验证校验码
        if (!isValidIdCardCheckCode(idCardNo)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO_FOR_TYPE);
        }

      /*  if (!validateBirthday(userCardInfoVo.getBirthday())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_BIRTHDAY);
        }*/


        return true;
    }

    public static boolean validateElseCard(UserCardValidationInfoReqVo userCardInfoVo) {
        String cardNo = userCardInfoVo.getCardNo();
        if(!validateCommonCardNo(cardNo)) {
            throw new CorpBusinessException(CommonResponseCodeEnum.FILL_IN_RIGHT_CARD_NO);
        }
      /*  //校验法定姓氏（英文）
        if(!isValidEnName(userCardInfoVo.getLastName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_LAST_NAME);
        }
        //校验法定名称（英文）
        if(!isValidEnName(userCardInfoVo.getFirstName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_FIRST_NAME);
        }
        if(!isValidCnName(userCardInfoVo.getCnName())) {
            throw new CorpBusinessException(CommonResponseCodeEnum.INVALID_LEGAL_NAME);
        }
*/

        return true;
    }


    public static boolean validForeignerLiveCardNo(String cardNo) {
        /**
         * 规则1：15位长度，前3位字母+12个数字
         * 规则2：第8-9位只能为 00 ~ 99，第10-11位只能为 01~12，第12-13位只能为 01~31
         */
        if (!cardNo.matches("^[A-Za-z]{3}\\d{12}$")) {
            return false;
        }

        String eighthToNinthDigits = cardNo.substring(7, 9);
        String tenthToEleventhDigits = cardNo.substring(9, 11);
        String twelfthToThirteenthDigits = cardNo.substring(11, 13);

        int eighthToNinth = Integer.parseInt(eighthToNinthDigits);
        int tenthToEleventh = Integer.parseInt(tenthToEleventhDigits);
        int twelfthToThirteenth = Integer.parseInt(twelfthToThirteenthDigits);

        if (eighthToNinth < 0 || eighthToNinth > 99 || tenthToEleventh < 1 || tenthToEleventh > 12 || twelfthToThirteenth < 1 || twelfthToThirteenth > 31) {
            return false;
        }
        return true;

    }


}